using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Chimera2.GUI
{
    public partial class Settings : Form
    {
        BotSettings botSettings = new BotSettings();

        // define delegate
        public delegate void PassControl(object sender);

        // create instance (null)
        public PassControl passControl;

        public Settings(BotSettings _botSettings)
        {
            InitializeComponent();
            botSettings = _botSettings;
            OnLoad();
        }

        private void OnLoad()
        {
            txtBotName.Text = botSettings.botName;
            txtBotDescription.Text = botSettings.botDescription;
            txtEmailAddress.Text = botSettings.botEmail;

            chkAutoConnect.Checked = botSettings.autoConnect;
            chkMinimizeToTray.Checked = botSettings.minimizeToTray;
            chkConfirmExit.Checked = botSettings.confirmExit;
        }

        private void OnSave()
        {
            botSettings.botName = txtBotName.Text;
            botSettings.botDescription = txtBotDescription.Text;
            botSettings.botEmail = txtEmailAddress.Text;

            botSettings.autoConnect = chkAutoConnect.Checked;
            botSettings.minimizeToTray = chkMinimizeToTray.Checked;
            botSettings.confirmExit = chkConfirmExit.Checked;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            OnSave();
            passControl(botSettings);
            this.Close();
        }
    }
}